/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package RootDesc.impl;

import RootDesc.RootDescPackage;
import RootDesc.RootDescription;
import RootDesc.TestDescription;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Root Description</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link RootDesc.impl.RootDescriptionImpl#getClassContext <em>Class Context</em>}</li>
 *   <li>{@link RootDesc.impl.RootDescriptionImpl#getTestDescriptions <em>Test Descriptions</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RootDescriptionImpl extends EObjectImpl implements RootDescription {
  /**
   * The default value of the '{@link #getClassContext() <em>Class Context</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getClassContext()
   * @generated
   * @ordered
   */
  protected static final String CLASS_CONTEXT_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getClassContext() <em>Class Context</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getClassContext()
   * @generated
   * @ordered
   */
  protected String classContext = CLASS_CONTEXT_EDEFAULT;

  /**
   * The cached value of the '{@link #getTestDescriptions() <em>Test Descriptions</em>}' reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTestDescriptions()
   * @generated
   * @ordered
   */
  protected EList<TestDescription> testDescriptions;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected RootDescriptionImpl() {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass() {
    return RootDescPackage.Literals.ROOT_DESCRIPTION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getClassContext() {
    return classContext;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setClassContext(String newClassContext) {
    String oldClassContext = classContext;
    classContext = newClassContext;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, RootDescPackage.ROOT_DESCRIPTION__CLASS_CONTEXT, oldClassContext, classContext));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<TestDescription> getTestDescriptions() {
    if (testDescriptions == null) {
      testDescriptions = new EObjectResolvingEList<TestDescription>(TestDescription.class, this, RootDescPackage.ROOT_DESCRIPTION__TEST_DESCRIPTIONS);
    }
    return testDescriptions;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType) {
    switch (featureID) {
      case RootDescPackage.ROOT_DESCRIPTION__CLASS_CONTEXT:
        return getClassContext();
      case RootDescPackage.ROOT_DESCRIPTION__TEST_DESCRIPTIONS:
        return getTestDescriptions();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue) {
    switch (featureID) {
      case RootDescPackage.ROOT_DESCRIPTION__CLASS_CONTEXT:
        setClassContext((String)newValue);
        return;
      case RootDescPackage.ROOT_DESCRIPTION__TEST_DESCRIPTIONS:
        getTestDescriptions().clear();
        getTestDescriptions().addAll((Collection<? extends TestDescription>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID) {
    switch (featureID) {
      case RootDescPackage.ROOT_DESCRIPTION__CLASS_CONTEXT:
        setClassContext(CLASS_CONTEXT_EDEFAULT);
        return;
      case RootDescPackage.ROOT_DESCRIPTION__TEST_DESCRIPTIONS:
        getTestDescriptions().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID) {
    switch (featureID) {
      case RootDescPackage.ROOT_DESCRIPTION__CLASS_CONTEXT:
        return CLASS_CONTEXT_EDEFAULT == null ? classContext != null : !CLASS_CONTEXT_EDEFAULT.equals(classContext);
      case RootDescPackage.ROOT_DESCRIPTION__TEST_DESCRIPTIONS:
        return testDescriptions != null && !testDescriptions.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString() {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (classContext: ");
    result.append(classContext);
    result.append(')');
    return result.toString();
  }

} //RootDescriptionImpl
